Skip to content

Reject overflowing output token estimates before admission - #980

Closed
Gajesh2007 wants to merge 4 commits into
masterfrom
fix/output-token-estimate-overflow
Closed

Gajesh2007 wants to merge 4 commits into
masterfrom
fix/output-token-estimate-overflow

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Sep 12, 2026 •

Copy link
Copy Markdown
Member

A large positive n multiplied by the requested output limit can overflow the generic inference estimate and bypass quota admission. A full or unlimited bucket also admits a saturated maximum-integer estimate, which can then wrap downstream cost and capacity calculations. Reject the invalid product with 400 invalid_request_error and param: "n" before quota, balance reservation or routing.

The shared estimator selects the existing explicit/default bound once and reports whether multiplication fits. Both inference callers use the same validation response. Fitting products retain their existing estimate, forwarded generation limits and one-burst quota policy. This PR handles multiplication overflow; #943 separately hardens prompt-plus-output sums. Existing numeric conversions and independently huge representable limits are outside this change.

flowchart LR
  subgraph Before
    A[Generic completions or messages] --> B[estimateRequestedMaxTokens]
    B --> C[Unchecked n times token bound]
    C --> D[Wrapped estimate reaches quota and billing]
  end
  subgraph After
    E[Inference request] --> F[estimateRequestedMaxTokens reports value and validity]
    F --> G[validateRequestedMaxTokens]
    G -->|overflow| H[400 invalid_request_error, param n]
    G -->|fits| I[Existing quota, reservation and routing]
  end
Loading

Validation:

  • Real HTTP fixtures reproduce positive and negative wraps on both generic routes against master. Existing half-burst and ordinary oversized controls remain.
  • Twelve additional HTTP cases reproduce the full/unlimited-quota issue against the earlier PR head (0.702s): both generic routes, both quota states, positive/negative/default-bound overflow. Every case reached billing and recorded a minimum-charge reserve plus refund. The final fixture requires 400 and only the original deposit in the real MemoryStore ledger.
  • Boundary cases preserve normal products, the largest fitting product, all three limit field names and the default bound. Final focused API race tests pass in 0.700s. The final full API race suite passes in 228.309s with database environment variables unset.
  • Two independent source/test reviews are clean. Signed commits, git diff --check and 278-page docs lint pass. API, consumer and routing docs describe the rejection boundary.

@vercel

vercel Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
d-inference Ready Ready Preview Sep 12, 2026 11:18pm UTC
d-inference-console-ui-dev Ready Ready Preview Sep 12, 2026 11:18pm UTC
d-inference-landing Ready Ready Preview Sep 12, 2026 11:18pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-12T23:22:46.910125Z aa3f30c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50a767cb54

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: aa3f30c7d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Gajesh2007

Copy link
Copy Markdown
Member Author

Consolidated into #1056 for review and merge after #1094, #1095 and #1096. #1056 contains this branch's exact head (aa3f30c7d726bc8311178a852b4a94dd6f5a437b), including its reviewed fixes, with implementations and regressions reconciled into the coordinator subsystem owners. Closing the component PR to collapse the stack; its branch, commits and review history are retained. Follow #1056 for combined validation and merge status.

@Gajesh2007 Gajesh2007 closed this Sep 16, 2026

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference — aa3f30c7 Deployed Sep 12, 2026 by vercel[bot]
Preview – d-inference-console-ui-dev — aa3f30c7 Deployed Sep 12, 2026 by vercel[bot]
Preview – d-inference-landing — aa3f30c7 Deployed Sep 12, 2026 by vercel[bot]
benchmarks — aa3f30c7 Deployed Sep 12, 2026 by Gajesh2007 via E2E Benchmarks #1087
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant